//    Copyright (C) 2013  <lugocreation@gmail.com>
//
//    This program is free software: you can redistribute it and/or modify
//    it under the terms of the GNU General Public License as published by
//    the Free Software Foundation, either version 3 of the License, or
//    (at your option) any later version.
//
//    This program is distributed in the hope that it will be useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//    GNU General Public License for more details.
//
//    You should have received a copy of the GNU General Public License
//    along with this program.  If not, see <http://www.gnu.org/licenses/>.
package org.jpgolay.me.search;

import java.awt.BorderLayout;
import javax.swing.*;
import org.jpgolay.gui.fixed.BasicMenu;
import org.jpgolay.gui.iconBar.IconBar;
import org.jpgolay.me.list.ListPanel;

public class SearchGUI extends JInternalFrame {

    public SearchGUI() {
        jContentPane = null;
        basicMenu = null;
        iconBar = null;
        jTabbedPane = null;
        piecesListPanel = null;
        customerListPanel = null;
        supplierListPanel = null;
        itemListPanel = null;
        initialize();
    }

    private void initialize() {
        setJMenuBar(getBasicMenu());
        setFrameIcon(new ImageIcon(getClass().getResource("/org/jpgolay/me/images/search18x18.png")));
        setTitle("Recherches");
        setSize(800, 600);
        setContentPane(getJContentPane());
    }

    private JPanel getJContentPane() {
        if (jContentPane == null) {
            jContentPane = new JPanel();
            jContentPane.setLayout(new BorderLayout());
            jContentPane.add(getIconBar(), "North");
            jContentPane.add(getJTabbedPane(), "Center");
        }
        return jContentPane;
    }

    private BasicMenu getBasicMenu() {
        if (basicMenu == null) {
            basicMenu = new BasicMenu();
        }
        return basicMenu;
    }

    private IconBar getIconBar() {
        if (iconBar == null) {
            iconBar = new IconBar();
        }
        return iconBar;
    }

    private JTabbedPane getJTabbedPane() {
        if (jTabbedPane == null) {
            jTabbedPane = new JTabbedPane();
            jTabbedPane.addTab("Pi\350ces", null, getPiecesListPanel(), null);
            jTabbedPane.addTab("Clients", null, getCustomerListPanel(), null);
            jTabbedPane.addTab("Fournisseurs", null, getSupplierListPanel(), null);
            jTabbedPane.addTab("Articles", null, getItemListPanel(), null);
        }
        return jTabbedPane;
    }

    private ListPanel getPiecesListPanel() {
        if (piecesListPanel == null) {
            piecesListPanel = new ListPanel();
        }
        return piecesListPanel;
    }

    private ListPanel getCustomerListPanel() {
        if (customerListPanel == null) {
            customerListPanel = new ListPanel();
        }
        return customerListPanel;
    }

    private ListPanel getSupplierListPanel() {
        if (supplierListPanel == null) {
            supplierListPanel = new ListPanel();
        }
        return supplierListPanel;
    }

    private ListPanel getItemListPanel() {
        if (itemListPanel == null) {
            itemListPanel = new ListPanel();
        }
        return itemListPanel;
    }

    public BasicMenu getMenuPanel() {
        return getBasicMenu();
    }

    public IconBar getIconBarPanel() {
        return getIconBar();
    }

    public ListPanel getPiecesList() {
        return getPiecesListPanel();
    }

    public ListPanel getCustomerList() {
        return getCustomerListPanel();
    }

    public ListPanel getSupplierList() {
        return getSupplierListPanel();
    }

    public ListPanel getItemList() {
        return getItemListPanel();
    }
    private JPanel jContentPane;
    private BasicMenu basicMenu;
    private IconBar iconBar;
    private JTabbedPane jTabbedPane;
    private ListPanel piecesListPanel;
    private ListPanel customerListPanel;
    private ListPanel supplierListPanel;
    private ListPanel itemListPanel;
}
